package cn.muqingfeng.api.to;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import cn.muqingfeng.api.Api;

import com.google.gson.annotations.SerializedName;

public class Article2TO implements Parcelable {
	@SerializedName("tid")
	private String id;

	@SerializedName("fid")
	private String fid;

	@SerializedName("subject")
	private String title;

	@SerializedName("authorid")
	private String authorId;

	@SerializedName("author")
	private String author;

	@SerializedName("image")
	private String cover;

	@SerializedName("dbdateline")
	private long publishTime;

	@SerializedName("replies")
	private int replyCount;

	public Article2TO() {
	}

	public Article2TO(Parcel source) {
		this.id = source.readString();
		this.title = source.readString();
		this.authorId = source.readString();
		this.author = source.readString();
		this.cover = source.readString();
		this.publishTime = source.readLong();
		this.replyCount = source.readInt();
		this.fid = source.readString();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(id);
		dest.writeString(title);
		dest.writeString(authorId);
		dest.writeString(author);
		dest.writeString(cover);
		dest.writeLong(publishTime);
		dest.writeInt(replyCount);
		dest.writeString(fid);
	}

	public static final Creator<Article2TO> CREATOR = new Creator<Article2TO>() {

		@Override
		public Article2TO[] newArray(int size) {
			return new Article2TO[size];
		}

		@Override
		public Article2TO createFromParcel(Parcel source) {
			return new Article2TO(source);
		}
	};

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuthorId() {
		return authorId;
	}

	public void setAuthorId(String authorId) {
		this.authorId = authorId;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getCover() {
		if (TextUtils.isEmpty(cover)) {
			return null;
		} else {
			if (cover.startsWith("http://") || cover.startsWith("https://")) {
				return cover;
			} else {
				return Api.IMAGE_HOST + cover;
			}
		}
	}

	public void setCover(String cover) {
		this.cover = cover;
	}

	public long getPublishTime() {
		return publishTime;
	}

	public void setPublishTime(long publishTime) {
		this.publishTime = publishTime;
	}

	public int getReplyCount() {
		return replyCount;
	}

	public void setReplyCount(int replyCount) {
		this.replyCount = replyCount;
	}

	public String getFid() {
		return fid;
	}

	public void setFid(String fid) {
		this.fid = fid;
	}

}
